package cn.trycat.field;


import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.util.Map;

public class CCC {

    public static void main(String[] args) {

        System.out.println("============"+Abc.class.getAnnotation(Foo.class).value());

        Foo foo = Abc.class.getAnnotation(Foo.class);

        System.out.println("4444444444==="+foo.value());
        System.out.println("4444444444==="+foo.count());

        InvocationHandler h = Proxy.getInvocationHandler(foo);

        try {
            Field hField = h.getClass().getDeclaredField("memberValues");
            hField.setAccessible(true);
            System.out.println("1111111==="+hField.getName());

            Map memberValues = (Map) hField.get(h);

            memberValues.put("value", "BBB");
            memberValues.put("count", 444);

            String value = foo.value();
            int count = foo.count();

            System.out.println("555555555555555555==="+value);
            System.out.println("555555555555555555==="+count);


        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
